package net.zdreamer.shunyi.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import net.zdreamer.shunyi.R;
import net.zdreamer.shunyi.utils.ListUtils.PaiHangInfos;
import net.zdreamer.shunyi.utils.ListUtils.PaiHangInfos.PaiHangInfo;
import net.zdreamer.shunyi.utils.ViewHolder;

import java.util.List;

/**
 * Created by Admin on 2014/12/29.
 */
public class PaiHangAdapter extends MyBaseAdapter<PaiHangInfo> implements View.OnClickListener {
    private TextView banghuiname, banghuixinxi;
    private ImageView banghuipicture, banghuichoose;
    private Context context;

    public PaiHangAdapter(Context context, List<PaiHangInfo> list, int res) {
        super(context, list, res);
        this.context=context;
    }

    @Override
    protected View getView(int position, View convertView, ViewGroup parent, PaiHangInfo value) {
        banghuiname = (TextView) ViewHolder.get(convertView, R.id.banghuiname);
        banghuixinxi = (TextView) ViewHolder.get(convertView, R.id.banghuixinxi);
        banghuipicture = (ImageView) ViewHolder.get(convertView, R.id.banghuipicture);
        banghuichoose = (ImageView) ViewHolder.get(convertView, R.id.banghuichoose);
        banghuiname.setText(value.Banghuiname);
        banghuixinxi.setText(value.Banghuixinxi);
        banghuipicture.setImageResource(value.banghuiicon.get(position).get("banghuiicon"));
        banghuichoose.setImageResource(value.ischeck.get(position).get("check"));

        banghuichoose.setOnClickListener(this);
        return convertView;
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.banghuichoose) {
            banghuichoose.setImageResource(R.drawable.ischecked);
        }
    }
}
